import 'package:gzmall_app/model/store.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:gzmall_app/model/shop_category.dart';
import 'package:gzmall_app/model/picture.dart';
import 'package:gzmall_app/model/brand.dart';
import 'package:gzmall_app/model/product_param.dart';
import 'package:gzmall_app/model/product_service.dart';
import 'package:gzmall_app/model/p_skus.dart';
import 'package:gzmall_app/model/p_option_type.dart';
import 'package:gzmall_app/model/coupon.dart';
import 'package:gzmall_app/model/comment.dart';

part 'product.g.dart';

@JsonSerializable()
class Product extends Object {
  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'name')
  String name;

  @JsonKey(name: 'sales_volume')
  int salesVolume;

  @JsonKey(name: 'avatar')
  String avatar;

  @JsonKey(name: 'description')
  String description;

  @JsonKey(name: 'published')
  bool published;

  @JsonKey(name: 'seven_day_back')
  bool sevenDayBack;

  @JsonKey(name: 'genuine_product')
  bool genuineProduct;

  @JsonKey(name: 'low_promotion_price')
  String lowPromotionPrice;

  @JsonKey(name: 'high_promotion_price')
  String highPromotionPrice;

  @JsonKey(name: 'low_sale_price')
  String lowSalePrice;

  @JsonKey(name: 'high_sale_price')
  String highSalePrice;

  @JsonKey(name: 'low_cost_price')
  String lowCostPrice;

  @JsonKey(name: 'high_cost_price')
  String highCostPrice;

  @JsonKey(name: 'shop_category')
  ShopCategory shopCategory;

  @JsonKey(name: 'brand')
  Brand brand;

  @JsonKey(name: 'shop')
  Store shop;

  @JsonKey(name: 'pictures')
  List<Picture> pictures;

  @JsonKey(name: 'parameters')
  List<ProductParam> parameters;

  @JsonKey(name: 'details')
  List<Picture> details;

  @JsonKey(name: 'service_items')
  List<ProductService> serviceItems;

  @JsonKey(name: 'skus')
  List<PSkus> skus;

  @JsonKey(name: 'option_type')
  List<POptionType> optionType;

  @JsonKey(name: 'coupons')
  List<Coupon> coupons;

  @JsonKey(name: 'comments')
  List<Comment> comments;

  @JsonKey(name: 'can_use_coupon')
  bool canUseCoupon;

  @JsonKey(name: 'favorited')
  bool favorited;

  @JsonKey(name: 'stock')
  int stock;

  @JsonKey(name: 'express_fee')
  String expressFee;

  @JsonKey(name: 'promotion')
  bool promotion;

  @JsonKey(name: 'service_url')
  String serviceUrl;

  @JsonKey(name: 'direct_sale')
  bool directSale;

  @JsonKey(name: 'share_title')
  String shareTitle;

  @JsonKey(name: 'share_content')
  String shareContent;

  @JsonKey(name: 'share_avatar')
  String shareAvatar;

  @JsonKey(name: 'share_url')
  String shareUrl;

  Product(
    this.id,
    this.name,
    this.salesVolume,
    this.avatar,
    this.description,
    this.published,
    this.sevenDayBack,
    this.genuineProduct,
    this.lowPromotionPrice,
    this.highPromotionPrice,
    this.lowSalePrice,
    this.highSalePrice,
    this.lowCostPrice,
    this.highCostPrice,
    this.shopCategory,
    this.brand,
    this.shop,
    this.pictures,
    this.parameters,
    this.details,
    this.serviceItems,
    this.skus,
    this.optionType,
    this.coupons,
    this.comments,
    this.canUseCoupon,
    this.favorited,
    this.stock,
    this.expressFee,
    this.promotion,
    this.serviceUrl,
    this.directSale,
    this.shareTitle,
    this.shareContent,
    this.shareAvatar,
    this.shareUrl,
  );

  factory Product.fromJson(Map<String, dynamic> srcJson) =>
      _$ProductFromJson(srcJson);

  Map<String, dynamic> toJson() {
    return _$ProductToJson(this);
  }
}
